package com.enzoism.springboot.dive;

import com.enzoism.springboot.dive.mock.MockDataSource;
import com.enzoism.springboot.dive.mock.MockDataSourceRunnable;
import com.enzoism.springboot.dive.mock.MockDataSourceService;
import com.enzoism.springboot.dive.result.RequestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@SpringBootApplication()
@RestController
@EnableAsync
public class DiveMainApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(DiveMainApplication.class, args);
        MockDataSource mockDataSource1 = context.getBean("mockDataSource", MockDataSource.class);
        MockDataSource mockDataSource2 = context.getBean("mockDataSource", MockDataSource.class);
        System.out.println("---->"+mockDataSource1);
        System.out.println("---->"+mockDataSource2);

    }
    @Autowired
    MockDataSourceService mockDataSourceService;

    @GetMapping("/")
    public RequestResult requestRedisLockResult() {
        mockDataSourceService.requestRedisLockResult();
        return RequestResult.success("zookeeper 请求成功：");
    }
}
